home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / System7 tools / Frontier / Frontier SDK 2.1 / Toolkits / Applet Toolkit / appletcursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-11  |  2.8 KB  |  171 lines  |  [TEXT/KAHL]

  1.  
  2. /*© Copyright 1988-1992 UserLand Software, Inc.  All Rights Reserved.*/
  3.  
  4.  
  5. #include "appletdefs.h"
  6. #include "appletcursor.h"
  7.  
  8.  
  9.  
  10. int lastcursor = cursorisdirty;
  11.    
  12. int beachballstate = cursorisbeachball4;
  13.  
  14. int earthstate = cursorisearth7;
  15.  
  16. long ticklastroll = 0;
  17.  
  18.  
  19.  
  20.  
  21. void setcursortype (newcursor) tycursortype newcursor; {
  22.     
  23.     /*
  24.     7/30/90 dmb:  don't assume that cursor is never changed behind your back
  25.     */
  26.     
  27.     register int cursor = newcursor;
  28.     register CursHandle hcursor;
  29.     
  30.     /*
  31.     if (cursor == lastcursor) /*no change%/
  32.         return;
  33.     */
  34.     
  35.     lastcursor = cursor; /*remember for next time*/
  36.     
  37.     if (cursor == cursorisdirty)
  38.         return;
  39.     
  40.     if (cursor == cursorisarrow) {
  41.         
  42.         ticklastroll = 0; /*disable rolling until reinitialized*/
  43.         
  44.         SetCursor (&arrow);
  45.         
  46.         return;
  47.         }
  48.     
  49.     hcursor = GetCursor (cursor);
  50.     
  51.     if (hcursor == nil) /*resource error*/
  52.         return;
  53.     
  54.     SetCursor (*hcursor);
  55.     } /*setcursortype*/
  56.  
  57.  
  58. void obscurecursor (void) {
  59.     
  60.     ObscureCursor ();
  61.     } /*obscurecursor*/
  62.  
  63.  
  64. static boolean rollingtimerexpired (void) {
  65.     
  66.     register long tc;
  67.     
  68.     if (ticklastroll == 0) /*timer hasn't been initted*/
  69.         return (false);
  70.     
  71.     tc = TickCount ();
  72.     
  73.     if ((ticklastroll + 6) > tc) /*a tenth of a second hasn't passed since last bump*/
  74.         return (false);
  75.         
  76.     ticklastroll = tc; /*enough time has passed, reset the timer*/
  77.     
  78.     return (true);
  79.     } /*rollingtimerexpired*/
  80.     
  81.     
  82. void initbeachball (void) {
  83.     
  84.     beachballstate = cursorisbeachball4;
  85.     
  86.     ticklastroll = TickCount ();
  87.     } /*initbeachball*/
  88.     
  89.     
  90. void rollbeachball (void) {
  91.     
  92.     register int state;
  93.     
  94.     if (rollingtimerexpired ()) {
  95.     
  96.         state = beachballstate + 1;
  97.         
  98.         if (state > cursorisbeachball4) /*wrap around*/
  99.             state = cursorisbeachball1;
  100.         
  101.         setcursortype (state);
  102.         
  103.         beachballstate = state;
  104.         }
  105.     } /*rollbeachball*/
  106.  
  107.  
  108. static boolean beachballcursor (void) {
  109.     
  110.     /*
  111.     return true if the cursor is one of the beachballs.
  112.     
  113.     12/26/90 dmb: new test accounts for the fact that, after an initbeachball, 
  114.     lastcursor won't be a beach ball until the timer has expired.  this test 
  115.     will return true if either rolling cursor is active (earth or beach ball)
  116.     */
  117.     
  118.     /*
  119.     return ((lastcursor >= cursorisbeachball1) && (lastcursor <= cursorisbeachball4));
  120.     */
  121.     
  122.     return (ticklastroll != 0);
  123.     } /*beachballcursor*/
  124.  
  125.  
  126. void initearth (void) {
  127.     
  128.     earthstate = cursorisearth1;
  129.     
  130.     ticklastroll = TickCount ();
  131.     } /*initearth*/
  132.  
  133.  
  134. void rollearth (void) {
  135.     
  136.     register int state;
  137.     
  138.     if (rollingtimerexpired ()) {
  139.     
  140.         state = earthstate + 1; 
  141.         
  142.         if (state > cursorisearth7) /*wrap around*/
  143.             state = cursorisearth1;
  144.                         
  145.         setcursortype (state);
  146.         
  147.         earthstate = state;
  148.         }
  149.     } /*rollearth*/
  150.  
  151.  
  152. void watchcursor () {
  153.     
  154.     register CursHandle hcursor;
  155.     
  156.     hcursor = GetCursor (watchCursor);
  157.     
  158.     if (hcursor != nil) 
  159.         SetCursor (*hcursor);
  160.     } /*watchcursor*/
  161.     
  162.     
  163. void arrowcursor () {
  164.     
  165.     SetCursor (&arrow);
  166.     } /*arrowcursor*/
  167.     
  168.     
  169.  
  170.  
  171.